﻿
@{
    ViewBag.Title = "个人资料";
    Layout = "~/Views/Shared/_Member.cshtml";
    var LoginMember = (QunProject.Model.member)ViewBag.LoginMember;
}
<div class="row p10 bcolor" style="overflow:auto;">
    <form class="layui-form" id="infoForm">
        <div class="layui-form-item">
            <label class="layui-form-label">头像设置</label>
            <div class="layui-input-inline" id="dot_img"></div>

            <script id="dot_tmp_img" type="text/x-dot-template">
                <img src="{{= _Member_Img_Url }}" id="displayImg" style="width:173px;height:173px;" onerror="memberImageError(event)">
            </script>
            <div class="layui-form-mid layui-word-aux">
                <a href="javascript:void(0)" class="href" onclick="javascript: { layer.msg('暂未实现'); }">选择默认头像</a>
                <br />
                <br />
                <a href="javascript:void(0)" class="href" onclick="javascript: { selectUpload(); }">上传头像</a>
            </div>
        </div>
        <div class="layui-form-item" hidden>
            <label class="layui-form-label">用户头像</label>
            <div class="layui-input-inline">
                <input type="text" id="dataImg" name="Img" placeholder="" class="layui-input" value="@LoginMember.Img" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">个人称呼</label>
            <div class="layui-input-inline">
                <input type="text" name="Name" placeholder="个人称呼" class="layui-input" value="@LoginMember.Name">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账号身份</label>
            <div class="layui-input-inline">
                <input type="text" name="Identity" placeholder="账号身份" class="layui-input" value="@LoginMember.Identity" readonly>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <a href="javascript:void(0)" class="href" onclick="javascript: { layer.msg('暂未实现'); }">选择展示身份</a>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">个人签名</label>
            <div class="layui-input-block">
                <textarea name="Introduce" placeholder="请输入内容" class="layui-textarea">@LoginMember.Introduce</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <a class="layui-btn" onclick="javascript: { info.submit(); }">保存资料</a>
            </div>
        </div>
    </form>
</div>

<script>
    var info = new Info();
    $(function () {
        info.initImg();
    });

    function Info() {
        this.initImg = function () {
            var dotTmp = doT.template($("#dot_tmp_img").text());
            $("#dot_img").html(dotTmp(null));
        };
        this.submit = function () {
            var paras = $('#infoForm').getForm();

            if (!paras.Name) {
                layer.msg('个人称呼不能为空');
                return;
            }

            $.post('/member/UserEditInfoResult', paras, function (result) {
                layer.confirm('保存成功', {
                    closeBtn: 0,
                    btn: ['确定']
                }, function () {
                    window.location.reload();
                });
            });
        };
    };

    function selectUpload() {
        tchUpload.open({
            onsave: function (data) {
                var paras = { base64: data };
                $('#displayImg').attr('src', data);
                $.post('/base/FileUpload', paras, function (result) {
                    $('#dataImg').val(result.data);
                });
            },
            onerror: function (msg) {
                layer.msg(msg);
            }
        });
    };
</script>